package Song.Han.Demo02;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;

/*
    一次输入多个字节
*/
public class Demo02InputStream {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("E:\\IDeaProject\\Day14\\src\\Song\\Han\\Demo01\\b.txt");

        byte[] bytes = new byte[2];
        int len = fis.read(bytes);
        System.out.println(len);//2  读取的优先数据个数
        //System.out.println(Arrays.toString(bytes));//[65, 66]
        System.out.println(new String(bytes));//AB

        len = fis.read(bytes);
        System.out.println(len);//2
        System.out.println(new String(bytes));//CD

        len = fis.read(bytes);
        System.out.println(len);//2
        System.out.println(new String(bytes));//EB

        len = fis.read(bytes);
        System.out.println(len);//1
        System.out.println(new String(bytes));//CB  只读取到一个C，放在bytes[0]处，故返回CB

        len = fis.read(bytes);
        System.out.println(len);//-1  没有读取到数据
        System.out.println(new String(bytes));//CB




        fis.close();
    }
}
